home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20031118-20041115 / 000367_fdc@columbia.edu_Fri Aug 20 09:26:14 2004.msg < prev    next >
Internet Message Format  |  2020-01-01  |  2KB

  1. Path: newsmaster.cc.columbia.edu!not-for-mail
  2. From: Frank da Cruz <fdc@columbia.edu>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: discovering remote directories via ftp
  5. Date: 20 Aug 2004 13:25:37 GMT
  6. Organization: Columbia University
  7. Lines: 44
  8. Message-ID: <slrncibuuh.ams.fdc@sesame.cc.columbia.edu>
  9. References: <c00b47e5.0408191310.6d364c08@posting.google.com>
  10. Reply-To: fdc@columbia.edu
  11. NNTP-Posting-Host: sesame.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1093008337 25022 128.59.59.56 (20 Aug 2004 13:25:37 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 20 Aug 2004 13:25:37 GMT
  15. User-Agent: slrn/0.9.8.0 (SunOS)
  16. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15129
  17.  
  18. On 2004-08-19, Logan <lcolby@magnaspeed.net> wrote:
  19. : The ftpdirectory script
  20. : (ftp://kermit.columbia.edu/kermit/scripts/ckermit/ftpdirectory) shows
  21. : how to get a file listing from a remote server. Is it possible to
  22. : extend this to directory listings? I'd like to be able to script the
  23. : retrieval of a file from the most recent directory d.x from [d.1, d.2,
  24. : ... d.z]. At the very least, can I redirect the results of a remote
  25. : dir either to a local variable or to a local file?
  26. :
  27. If the server includes directories in its NLST reply.  Some do, some
  28. don't.  Or if the server supports MLSD:
  29.  
  30.   http://www.columbia.edu/kermit/newftp.html
  31.  
  32. Assuming the server's NLST reply includes directories, you can modify
  33. the ftpdirectory script to test for this by trying to CD to each file.
  34. If it succeeds, it's a directory (and you have to remember to CDUP to
  35. get back where you were); if it fails, it's (probably) an ordinary file.
  36.  
  37.   undef dir
  38.   ftp cd \m(name)
  39.   if success {
  40.       ftp cdup
  41.       .dir := "(DIRECTORY)"
  42.   }
  43.   echo "\flpad(\m(size),12) \fcvtdate(\m(time)) \m(name) \m(dir)" ; Show info
  44.  
  45. Unfortunately, most FTP servers do NOT return directory names in their
  46. NLST replies, nor do they support MLSD.  This is one of many reasons we
  47. created IKSD:
  48.  
  49.   http://www.columbia.edu/kermit/iksd.html
  50.  
  51. It gets around FTP limitations such as this one, and many others too.
  52.  
  53. If the FTP server does not report directories and you can't install IKSD on
  54. the server, your only other alternative is to use LIST, save the result to
  55. a file:
  56.  
  57.   ftp directory * > localfilename
  58.  
  59. and "parse" the file.
  60.  
  61. - Frank